In [1]:
from numpy import sin,cos,sqrt,pi
from qutip import *
In [2]:
H = Qobj([[1],[0]])
V = Qobj([[0],[1]])
P45 = Qobj([[1/sqrt(2)],[1/sqrt(2)]])
M45 = Qobj([[1/sqrt(2)],[-1/sqrt(2)]])
R = Qobj([[1/sqrt(2)],[-1j/sqrt(2)]])
L = Qobj([[1/sqrt(2)],[1j/sqrt(2)]])
The sim_transform function creates the matrix $\bar{\mathbf{S}}$ that can convert from one basis to another. As an example, it will create the tranform matrix to convert from HV to ±45 if you run:
Shv45 = sim_transform(H,V,P45,M45) # creates the matrix Shv45
Then you can convert a ket from HV to ±45 by applying the Shv45 matrix:
Shv45*H # will convert H from the HV basis to the ±45 basis
To convert operators, you have to sandwich the operator between $\bar{\mathbf{S}}$ and $\bar{\mathbf{S}}^\dagger$:
Shv45*Ph*Shv45.dag() # converts Ph from HV basis to the ±45 basis.
In [3]:
def sim_transform(o_basis1, o_basis2, n_basis1, n_basis2):
a = n_basis1.dag()*o_basis1
b = n_basis1.dag()*o_basis2
c = n_basis2.dag()*o_basis1
d = n_basis2.dag()*o_basis2
return Qobj([[a.data[0,0],b.data[0,0]],[c.data[0,0],d.data[0,0]]])
In [4]:
def Rp(theta):
return Qobj([[cos(theta),-sin(theta)],[sin(theta),cos(theta)]]).tidyup()
In [5]:
Shv45 = sim_transform(H,V,P45,M45)
In [6]:
Rp45 = Shv45*Rp(pi/4)*Shv45.dag()
In [7]:
Rp45*Shv45*P45 == Shv45*V # convert P45 to the ±45 basis
Out[7]:
In [8]:
Rp45* Qobj([[1],[0]])
Out[8]:
In [9]:
ShvLR = sim_transform(H,V,L,R)
In [10]:
ShvLR*Rp(pi/4)*ShvLR.dag()
Out[10]:
In [ ]: